package net.sunofbeach.blog.service.impl;

import net.sunofbeach.blog.config.EmailSender;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 异步发送邮件
 *
 * @author bing_  @create 2021/11/27-15:34
 */
@Service
public class TaskService {

    @Resource
    private EmailSender emailSender;

    /**
     * 异步发送验证码邮件
     *
     * @param verifyCode
     * @param emailAddress
     * @throws Exception
     */
    @Async
    public void sendEmailVerifyCode(String verifyCode, String emailAddress) throws Exception {
        emailSender.sendEmail(verifyCode, emailAddress);
    }


    /**
     * 异步发送邮件通知文章作者新增了评论
     *
     * @param emailAddress
     * @param notifyContent
     * @throws Exception
     */
    @Async
    public void sendCommentNotifyEmail(String emailAddress, String articleTitle, String notifyContent) throws Exception {
        emailSender.sendCommentNotifyEmail(emailAddress, articleTitle, notifyContent);
    }
}